define(`TOHWM4_geometry_subs', `dnl
  subroutine cmlAddLength_$1(xf, id, atomRef1, atomRef2, length, fmt)
    type(xmlf_t), intent(inout) :: xf
    character(len=*), intent(in) :: id
    character(len=*), intent(in) :: atomRef1
    character(len=*), intent(in) :: atomRef2
    real(kind=$1), intent(in)    :: length
    character(len=*), intent(in), optional :: fmt

#ifndef DUMMYLIB
    call xml_NewElement(xf, "length")
    call xml_AddAttribute(xf, "id", trim(id))
    call xml_AddAttribute(xf, "atomRefs2", trim(atomRef1)//" "//trim(atomRef2))
    call xml_AddCharacters(xf, length, fmt)
    call xml_EndElement(xf, "length")
#endif

  end subroutine cmlAddLength_$1

  subroutine cmlAddAngle_$1(xf, id, atomRef1, atomRef2, atomRef3, angle, fmt)
    type(xmlf_t), intent(inout) :: xf
    character(len=*), intent(in) :: id
    character(len=*), intent(in) :: atomRef1
    character(len=*), intent(in) :: atomRef2
    character(len=*), intent(in) :: atomRef3
    real(kind=$1), intent(in)     :: angle
    character(len=*), intent(in), optional :: fmt

#ifndef DUMMYLIB
    call xml_NewElement(xf, "angle")
    call xml_AddAttribute(xf, "id", trim(id))
    call xml_AddAttribute(xf, "atomRefs3", trim(atomRef1)//" "//trim(atomRef2)//" "//trim(atomRef3))
    call xml_AddCharacters(xf, angle, fmt)
    call xml_EndElement(xf, "angle")
#endif

  end subroutine cmlAddAngle_$1

  subroutine cmlAddTorsion_$1(xf, id, atomRef1, atomRef2, atomRef3, atomRef4, torsion, fmt)
    type(xmlf_t), intent(inout) :: xf
    character(len=*), intent(in) :: id
    character(len=*), intent(in) :: atomRef1
    character(len=*), intent(in) :: atomRef2
    character(len=*), intent(in) :: atomRef3        ! ref to third atom
    character(len=*), intent(in) :: atomRef4
    real(kind=$1), intent(in)    :: torsion
    character(len=*), intent(in), optional :: fmt

#ifndef DUMMYLIB
    call xml_NewElement(xf, "torsion")
    call xml_AddAttribute(xf, "id", trim(id))
    call xml_AddAttribute(xf, "atomRefs4", &
         trim(atomRef1)//" "//trim(atomRef2)//" "//trim(atomRef3)//" "//trim(atomRef4))
    call xml_AddCharacters(xf, torsion, fmt)
    call xml_EndElement(xf, "torsion")
#endif

  end subroutine cmlAddTorsion_$1
')dnl
dnl
!
! This file is AUTOGENERATED
! To update, edit m_wcml_geometry.m4 and regenerate

module m_wcml_geometry

  use fox_m_fsys_realtypes, only: sp, dp
  use FoX_wxml, only: xmlf_t
#ifndef DUMMYLIB
  use FoX_wxml, only: xml_NewElement, xml_EndElement
  use FoX_wxml, only: xml_AddAttribute, xml_AddCharacters

! Fix for pgi, requires this explicitly:
  use m_wxml_overloads
#endif

  implicit none
  private

  interface cmlAddLength
    module procedure cmlAddLength_SP, cmlAddLength_DP
  end interface

  interface cmlAddAngle
    module procedure cmlAddAngle_SP, cmlAddAngle_DP
  end interface

  interface cmlAddTorsion
    module procedure cmlAddTorsion_SP, cmlAddTorsion_DP
  end interface

  public :: cmlAddLength
  public :: cmlAddAngle
  public :: cmlAddTorsion

contains

TOHWM4_geometry_subs(`sp')

TOHWM4_geometry_subs(`dp')

end module m_wcml_geometry
